/**
 * 2
 *
 * @Author : roryrywang
 * @DateTime : 24-8-24 下午1:32
 */

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a;
    unordered_map<int, int> map;

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
        map[x]++;
    }

    int mex = 0;
    while (map.count(mex)) mex++;

    for (int i: a) {
        if (i < mex && map[i] == 1) {
            cout << i << " ";
        } else {
            cout << mex << " ";
        }
    }

    return 0;
}